<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <script>

    var person = {
      name: "张三",
      age: 20
    }
    // var { name, age } = person;
    // 基本解构
    var { name, age } = { name: "张三", age: 20 }
    console.log(name, age);
    var { name3: age } = { name3: "admin" };
    console.log(age);

    //嵌套
    let obj = { id: ['admin', { sex: '男' }] }

    let { id: [name1, { sex }] } = { id: ['admin', { sex: '男' }] };

    console.log(name1);
    console.log(sex);

    //剩余运算符
    let { a, b, ...args } = { a: 11, b: 22, c: 33, d: 44, e: 55 }
    console.log(a);
    console.log(b);
    console.log(args);
    //默认值

    let { m = 1, n = 2 } = {}
    console.log(m, n);
  </script>
</body>

</html>